package com.controller;


import com.Service.ExaminationprojectService;
import com.dao.ExaminationprojectMapper;
import com.model.pojo.Examinationproject;
import com.model.pojo.Sheet;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("/doShow")
public class ExaminationprojectController {

    /**
     * 数据源
     */
    @Resource
    private ExaminationprojectService examinationprojectService;


    @RequestMapping("/toList")
    public String doShow(Examinationproject examinationproject,Model model){
        //显示所有信息
        List<Examinationproject> examinationprojectList = examinationprojectService.doExaminationprojecShow(examinationproject);
        model.addAttribute("examinationprojectList",examinationprojectList);

        return "examinationlist";
    }
    @RequestMapping("/toadd")
    public String toadd(){
        //页面跳转显示
        return "examinationAdd";
    }
    @RequestMapping("/doadd")
    public String doadd(Examinationproject examinationproject){
        //添加操作
        boolean flag = examinationprojectService.doExaminationprojecAdd(examinationproject);
        return "redirect:/doShow/toList";
    }
    @RequestMapping("/toupdate")
    public String toupdate(Examinationproject examinationproject,Model model){
        //修改页面跳转显示
        Examinationproject examinationproject1=examinationprojectService.findExaminationprojectById(examinationproject);
        model.addAttribute("examinationproject1",examinationproject1);

        return "examinationUpdate";
    }
    @RequestMapping("/doupdate")
    public String doupdate(Examinationproject examinationproject, HttpSession session){
        //修改操作
        boolean flag = examinationprojectService.doExaminationprojectUpdate(examinationproject);
        session.setAttribute("msg","修改成功");

        return "redirect:/doShow/toList";
    }
    @RequestMapping("/dodelect")
    public String dodelect(Examinationproject examinationproject, HttpSession session){
        //删除操作
        boolean flag = examinationprojectService.doExaminationprojectDelect(examinationproject);
        session.setAttribute("msg","删除成功");

        return "redirect:/doShow/toList";
    }





    @RequestMapping("/allPrintShow")
    public String allPrintShow(HttpSession session){
        List<Sheet> SheetListo = examinationprojectService.allPrintShow();
        System.out.println(SheetListo);
        session.setAttribute("SheetListo",SheetListo);

        return "allPrintShow";
    }

    @RequestMapping("/allPrint")
    public String allPrint(HttpSession session,String sheetDimensioncode){
        List<Examinationproject> examinationProjectListo = examinationprojectService.allPrint(sheetDimensioncode);
        List<Sheet>    sheetListw = examinationprojectService.textcontent(sheetDimensioncode);
        session.setAttribute("ExaminationprojectListo",examinationProjectListo);
        session.setAttribute("sheetListw",sheetListw);
        System.out.println(sheetListw);

        return "allPrint";
    }

    @RequestMapping("/allPrinttrue")
    public String allPrinttrue(){


        return "allPrintcopy";
    }

}
